<script setup>
import axios from "axios";
import Test from './test.vue'
import RouterTest from './router_test.vue'
import { ref , onMounted,getCurrentInstance} from 'vue'
import request from "../util/request"

defineProps({
  msg: String,
})


// export function getInfo() {
//   return request({
//     url: "/api/getInfo/",
//     method: "get"
//   });
// }

const count = ref(0)

// let { proxy } = getCurrentInstance();
onMounted(()=>{
  $eventBus.on("updateNum",()=>{
    count.value++
  });
  console.log(import.meta.env)
})


let flag = false
const addEvent = () =>{
  console.log(flag)
  if (!flag){
    $eventBus.on("updateNum",()=>{
      count.value++
    });
    flag = true;
  }
  // const response = axios.get("https://xielei-yy.com/api/checkUser/")
  // response.then(res=>{
  //   console.log(res)
  // })
}


const updateNum = () => {
  count.value--
}
</script>

<template>
  <h1>{{process}}</h1>
  <h1>{{count}}</h1>
  <div class="t-text-color">Hello world</div>
  <el-button @click="updateNum">减少</el-button>
  <el-button  @click="addEvent">添加事件总线</el-button>
  <Test></Test>
  <RouterTest></RouterTest>
</template>

<style scoped>
.read-the-docs {
  color: #888;
}
</style>

<style lang="scss" scoped>
//.text-color{
//  color: $red;
//}
.t-text-color {
  color: $test-color;
}
</style>
